package utils;

import java.sql.Time;
import java.util.Date;


public class TimeSpan 
{
	public Date beginTime;
	public Date endTime;
	
	public TimeSpan(Date time)
	{
		this.beginTime = time;
		this.endTime = time;
	}
	
	
	public TimeSpan(Date beginTime, Date endTime)
	{
		this.beginTime = beginTime;
		this.endTime = endTime;
	}
	
	public TimeSpan(long beginTime, long endTime) {
		this.beginTime = new Time(beginTime);
		this.endTime = new Time(endTime);
	}


	@Override 
	public boolean equals(Object o)
	{
		TimeSpan t2 = (TimeSpan)o;
		return (this.beginTime == t2.beginTime && this.endTime == t2.endTime);
	}
	
	public boolean contains(Time time)
	{
		return (time.after(beginTime) && time.before(endTime));
	}
	
	public boolean contains(TimeSpan intervalle)
	{
		return (  intervalle.beginTime.after(this.beginTime) && intervalle.endTime.before(this.endTime) );
	}
	
	@Override
	public String toString()
	{
		return "[beginTime: " + beginTime + "; endTime: " + endTime+"]";
	}
}
